//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
typedef unsigned long long ull;
using namespace std;

int arr[1005];
bool vis[100005];
bool you[100005];
vector<set<int>>obs(1000005);

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    memset(vis, false, sizeof(vis));
    memset(you, false, sizeof(you));
    set<int>se;
    for (int i = 1;i <= n;i++) {
        for (int j = 1;j <= m;j++) {
            int tmp;
            cin >> tmp;
            se.insert(tmp);
            you[tmp] = true;
            if (i == 1) {
                arr[j] = tmp;
                continue;
            }
            if (arr[j] != tmp) {
                obs[tmp].insert(arr[j]);
            }
            arr[j] = tmp;
        }
    }
    int len = se.size(), flag = 0, count = 0, fu = 0;
    while (!se.empty()) {
        for (int i = 1;i <= len;i++) {
            if (vis[i] || !you[i])
                continue;
            if (obs[i].size() != 0) {
                vector<int>tmpE;
                for (auto at : obs[i]) {
                    if (vis[at] == true) {
                        tmpE.push_back(at);

                    }
                }
                for (auto at : tmpE) {
                    obs[i].erase(at);
                }
            }
            if (obs[i].size() == 0) {
                if (flag == 0)
                    cout << i;
                else
                    cout << " " << i;
                flag = 1;
                vis[i] = true;
                count++;
                se.erase(i);
                break;
            }

        }
        if (count == 0 && fu == 0) {
            fu = 1;
        }
        else if (count == 0 && fu == 1) {
            if (flag == 0)
                cout << "Impossible";
            else
                cout << " Impossible";
        }
        else if (count != 0 && fu == 1)
            fu = 0;
    }
    return 0;
}